/*
 * Created on Nov 17, 2003
 */
package com.unash.z3950.pdu;

/**
 * @author Ashwini Gokhale
 */

import com.unash.asn.AsnBitString;
import com.unash.asn.AsnBoolean;
import com.unash.asn.AsnInteger;
import com.unash.asn.AsnOctetString;
import com.unash.asn.AsnVisibleString;


public class InitRequest implements Request {
	private AsnOctetString referenceId;
	private AsnBitString protocolVersion;
	private AsnBitString options;
	private AsnInteger preferredMessageSize;
	private AsnInteger exceptionalRecordSize;
	//TODO: idAuthentication [ANY optional]
	private AsnVisibleString implementationId;
	private AsnVisibleString implementationName;
	private AsnVisibleString implementationVersion;
	//TODO: userInformationField [EXTERNAL Optional]
	//TODO: otherInformation [OtherInformation Optional]
	
	
	public Response process(){
		InitResponse objResponse = new InitResponse();
		
		
		if((protocolVersion == null)      || (options==null) || 
		   (preferredMessageSize == null) || (exceptionalRecordSize == null))
		   		System.out.println("Init request not complete.");
		
		objResponse.setProtocolVersion(protocolVersion);
		objResponse.setOptions(options);
		objResponse.setPreferredMessageSize(preferredMessageSize);
		objResponse.setExceptionalRecordSize(exceptionalRecordSize);
		objResponse.setResult(new AsnBoolean(true));
		
		//optional fields
		objResponse.setReferenceId(referenceId);
		objResponse.setImplementationId(implementationId);
		//objResponse.setImplementationName(implementationName);
		objResponse.setImplementationName(new AsnVisibleString("UnAshServer"));
		//objResponse.setImplementationVersion(implementationVersion);
		objResponse.setImplementationVersion(new AsnVisibleString("1.0"));
		
				
		return objResponse;
	}//Process
	
	
	/**
	 * @return
	 */
	public AsnInteger getExceptionalRecordSize() {
		return exceptionalRecordSize;
	}

	/**
	 * @return
	 */
	public AsnVisibleString getImplementationId() {
		return implementationId;
	}

	/**
	 * @return
	 */
	public AsnVisibleString getImplementationName() {
		return implementationName;
	}

	/**
	 * @return
	 */
	public AsnVisibleString getImplementationVersion() {
		return implementationVersion;
	}

	/**
	 * @return
	 */
	public AsnBitString getOptions() {
		return options;
	}

	/**
	 * @return
	 */
	public AsnInteger getPreferredMessageSize() {
		return preferredMessageSize;
	}

	/**
	 * @return
	 */
	public AsnBitString getProtocolVersion() {
		return protocolVersion;
	}

	/**
	 * @return
	 */
	public AsnOctetString getReferenceId() {
		return referenceId;
	}

	/**
	 * @param integer
	 */
	void setExceptionalRecordSize(AsnInteger integer) {
		exceptionalRecordSize = integer;
	}

	/**
	 * @param string
	 */
	void setImplementationId(AsnVisibleString string) {
		implementationId = string;
	}

	/**
	 * @param string
	 */
	void setImplementationName(AsnVisibleString string) {
		implementationName = string;
	}

	/**
	 * @param string
	 */
	void setImplementationVersion(AsnVisibleString string) {
		implementationVersion = string;
	}

	/**
	 * @param string
	 */
	void setOptions(AsnBitString string) {
		options = string;
	}

	/**
	 * @param integer
	 */
	void setPreferredMessageSize(AsnInteger integer) {
		preferredMessageSize = integer;
	}

	/**
	 * @param string
	 */
	void setProtocolVersion(AsnBitString string) {
		protocolVersion = string;
	}

	/**
	 * @param string
	 */
	void setReferenceId(AsnOctetString string) {
		referenceId = string;
	}

}//InitRequest
